package ua.cn.store.service;
import java.util.List;

import ua.cn.store.domain.Domain;


/**
 * @param <T>
 *  Domain class to work with
 */
public interface IGenericService<T extends Domain> {
	
	/**
	 * Save new object in the DB
	 * @param object to store
	 * @return stored object
	 * @throws IllegalArgumentException if parameter is <code>null</code>
	 * @throws GeneralServiceException if DB error occurs
	 */
	public T add(T obj) throws IllegalArgumentException,
	GeneralServiceException;
	
	/**
	 * Delete object from DB
	 * @param object to delete
	 * @throws IllegalArgumentException if parameter is <code>null</code>
	 * @throws GeneralServiceException if DB error occurs
	 */
	public void delete(T obj) throws IllegalArgumentException,
	GeneralServiceException;
		
	/**
	 * Getting all objects 
	 * @return List of all entities of T type
	 */
	public List<T> getAll();
	
	/**
	 * Find object by id
	 * @param id
	 * @return object
	 * @throws IllegalArgumentException if parameter is <code>null</code>
	 */
	public T findById(Long id)throws IllegalArgumentException;
	
}
